package com.webcamtracker.image.color.hsi;

import com.webcamtracker.image.Color;
import com.webcamtracker.utils.MathFunctions;


public class HSIColor implements Color {

    private double hue;
    private double saturation;
    private double intensity;

    public HSIColor(double hue, double saturation, double intensity) {
        this.hue = hue;
        this.intensity = intensity;
        this.saturation = saturation;
    }

    public double getHue() {
        return hue;
    }

    public void setHue(double hue) {
        this.hue = hue;
    }

    public double getIntensity() {
        return intensity;
    }

    public void setIntensity(double intensity) {
        this.intensity = intensity;
    }

    public double getSaturation() {
        return saturation;
    }

    public void setSaturation(double saturation) {
        this.saturation = saturation;
    }


    public String toString() {
        return "HSIColor{" +
                "hue=" + hue +
                ", saturation=" + saturation +
                ", intensity=" + intensity +
                '}';
    }

    public boolean isSimilar(Color searchColor, double threadsHold) {
        double colorMatrix[] = new double[]{getHue(), getSaturation()};
        double searchColorMatrix[] = new double[]{((HSIColor) searchColor).getHue(), ((HSIColor) searchColor).getSaturation()};
        double distance = MathFunctions.euclideanDistance(colorMatrix, searchColorMatrix);
        return distance <= threadsHold;
    }

    public double[] elements() {
        return new double[]{getHue(), getSaturation(), getIntensity()};
    }

}
